﻿using Microsoft.Xna.Framework;
using GoblinXNA.Physics;
namespace ping
{
    public partial class Ping
    {
        public void initializeMaterials()
        {
            physicsMaterials = new NewtonMaterial[27];
            physicsMaterials[0] = new NewtonMaterial();
            physicsMaterials[0].MaterialName1 = "ball";
            physicsMaterials[0].MaterialName2 = "paddle";
            physicsMaterials[0].Elasticity = 1f;
            physicsMaterials[0].StaticFriction = 0;
            // Define a callback function that will be called when the ball and paddle collide
            physicsMaterials[0].ContactProcessCallback = delegate(Vector3 contactPosition, Vector3 contactNormal,
                float contactSpeed, float colObj1ContactTangentSpeed, float colObj2ContactTangentSpeed,
                Vector3 colObj1ContactTangentDirection, Vector3 colObj2ContactTangentDirection)
            {
                // Method to play a sound when the ball and paddle collide based on contactSpeed
                ballPaddleCollision(contactSpeed, contactPosition);
            };
            ((NewtonPhysics)scene.PhysicsEngine).AddPhysicsMaterial(physicsMaterials[0]);

            for (int i = 1; i < 27; i++)
            {
                physicsMaterials[i] = new NewtonMaterial();
                physicsMaterials[i].MaterialName1 = "ball";
                physicsMaterials[i].MaterialName2 = "paddleWithNote_" + i.ToString();
                physicsMaterials[i].Elasticity = 1f;
                physicsMaterials[i].StaticFriction = 0;
            }

            physicsMaterials[1].ContactProcessCallback = delegate(Vector3 contactPosition, Vector3 contactNormal,
             float contactSpeed, float colObj1ContactTangentSpeed, float colObj2ContactTangentSpeed,
             Vector3 colObj1ContactTangentDirection, Vector3 colObj2ContactTangentDirection)
            {
                // Method to play a sound when the ball and paddle collide based on contactSpeed
                ballPaddleCollision(1 + offSet, contactPosition);
            };

            physicsMaterials[2].ContactProcessCallback = delegate(Vector3 contactPosition, Vector3 contactNormal,
             float contactSpeed, float colObj1ContactTangentSpeed, float colObj2ContactTangentSpeed,
             Vector3 colObj1ContactTangentDirection, Vector3 colObj2ContactTangentDirection)
            {
                // Method to play a sound when the ball and paddle collide based on contactSpeed
                ballPaddleCollision(2 + offSet, contactPosition);
            };

            physicsMaterials[3].ContactProcessCallback = delegate(Vector3 contactPosition, Vector3 contactNormal,
             float contactSpeed, float colObj1ContactTangentSpeed, float colObj2ContactTangentSpeed,
             Vector3 colObj1ContactTangentDirection, Vector3 colObj2ContactTangentDirection)
            {
                // Method to play a sound when the ball and paddle collide based on contactSpeed
                ballPaddleCollision(3 + offSet, contactPosition);
            };

            physicsMaterials[4].ContactProcessCallback = delegate(Vector3 contactPosition, Vector3 contactNormal,
             float contactSpeed, float colObj1ContactTangentSpeed, float colObj2ContactTangentSpeed,
             Vector3 colObj1ContactTangentDirection, Vector3 colObj2ContactTangentDirection)
            {
                // Method to play a sound when the ball and paddle collide based on contactSpeed
                ballPaddleCollision(4 + offSet, contactPosition);
            };

            physicsMaterials[5].ContactProcessCallback = delegate(Vector3 contactPosition, Vector3 contactNormal,
             float contactSpeed, float colObj1ContactTangentSpeed, float colObj2ContactTangentSpeed,
             Vector3 colObj1ContactTangentDirection, Vector3 colObj2ContactTangentDirection)
            {
                // Method to play a sound when the ball and paddle collide based on contactSpeed
                ballPaddleCollision(5 + offSet, contactPosition);
            };

            physicsMaterials[6].ContactProcessCallback = delegate(Vector3 contactPosition, Vector3 contactNormal,
             float contactSpeed, float colObj1ContactTangentSpeed, float colObj2ContactTangentSpeed,
             Vector3 colObj1ContactTangentDirection, Vector3 colObj2ContactTangentDirection)
            {
                // Method to play a sound when the ball and paddle collide based on contactSpeed
                ballPaddleCollision(6 + offSet, contactPosition);
            };

            physicsMaterials[7].ContactProcessCallback = delegate(Vector3 contactPosition, Vector3 contactNormal,
             float contactSpeed, float colObj1ContactTangentSpeed, float colObj2ContactTangentSpeed,
             Vector3 colObj1ContactTangentDirection, Vector3 colObj2ContactTangentDirection)
            {
                // Method to play a sound when the ball and paddle collide based on contactSpeed
                ballPaddleCollision(7 + offSet, contactPosition);
            };

            physicsMaterials[8].ContactProcessCallback = delegate(Vector3 contactPosition, Vector3 contactNormal,
             float contactSpeed, float colObj1ContactTangentSpeed, float colObj2ContactTangentSpeed,
             Vector3 colObj1ContactTangentDirection, Vector3 colObj2ContactTangentDirection)
            {
                // Method to play a sound when the ball and paddle collide based on contactSpeed
                ballPaddleCollision(8 + offSet, contactPosition);
            };

            physicsMaterials[9].ContactProcessCallback = delegate(Vector3 contactPosition, Vector3 contactNormal,
             float contactSpeed, float colObj1ContactTangentSpeed, float colObj2ContactTangentSpeed,
             Vector3 colObj1ContactTangentDirection, Vector3 colObj2ContactTangentDirection)
            {
                // Method to play a sound when the ball and paddle collide based on contactSpeed
                ballPaddleCollision(9 + offSet, contactPosition);
            };

            physicsMaterials[10].ContactProcessCallback = delegate(Vector3 contactPosition, Vector3 contactNormal,
             float contactSpeed, float colObj1ContactTangentSpeed, float colObj2ContactTangentSpeed,
             Vector3 colObj1ContactTangentDirection, Vector3 colObj2ContactTangentDirection)
            {
                // Method to play a sound when the ball and paddle collide based on contactSpeed
                ballPaddleCollision(10 + offSet, contactPosition);
            };

            physicsMaterials[11].ContactProcessCallback = delegate(Vector3 contactPosition, Vector3 contactNormal,
             float contactSpeed, float colObj1ContactTangentSpeed, float colObj2ContactTangentSpeed,
             Vector3 colObj1ContactTangentDirection, Vector3 colObj2ContactTangentDirection)
            {
                // Method to play a sound when the ball and paddle collide based on contactSpeed
                ballPaddleCollision(11 + offSet, contactPosition);
            };

            physicsMaterials[12].ContactProcessCallback = delegate(Vector3 contactPosition, Vector3 contactNormal,
             float contactSpeed, float colObj1ContactTangentSpeed, float colObj2ContactTangentSpeed,
             Vector3 colObj1ContactTangentDirection, Vector3 colObj2ContactTangentDirection)
            {
                // Method to play a sound when the ball and paddle collide based on contactSpeed
                ballPaddleCollision(12 + offSet, contactPosition);
            };

            physicsMaterials[13].ContactProcessCallback = delegate(Vector3 contactPosition, Vector3 contactNormal,
             float contactSpeed, float colObj1ContactTangentSpeed, float colObj2ContactTangentSpeed,
             Vector3 colObj1ContactTangentDirection, Vector3 colObj2ContactTangentDirection)
            {
                // Method to play a sound when the ball and paddle collide based on contactSpeed
                ballPaddleCollision(13 + offSet, contactPosition);
            };

            physicsMaterials[14].ContactProcessCallback = delegate(Vector3 contactPosition, Vector3 contactNormal,
             float contactSpeed, float colObj1ContactTangentSpeed, float colObj2ContactTangentSpeed,
             Vector3 colObj1ContactTangentDirection, Vector3 colObj2ContactTangentDirection)
            {
                // Method to play a sound when the ball and paddle collide based on contactSpeed
                ballPaddleCollision(14 + offSet, contactPosition);
            };

            physicsMaterials[15].ContactProcessCallback = delegate(Vector3 contactPosition, Vector3 contactNormal,
             float contactSpeed, float colObj1ContactTangentSpeed, float colObj2ContactTangentSpeed,
             Vector3 colObj1ContactTangentDirection, Vector3 colObj2ContactTangentDirection)
            {
                // Method to play a sound when the ball and paddle collide based on contactSpeed
                ballPaddleCollision(15 + offSet, contactPosition);
            };
            physicsMaterials[16].ContactProcessCallback = delegate(Vector3 contactPosition, Vector3 contactNormal,
             float contactSpeed, float colObj1ContactTangentSpeed, float colObj2ContactTangentSpeed,
             Vector3 colObj1ContactTangentDirection, Vector3 colObj2ContactTangentDirection)
            {
                // Method to play a sound when the ball and paddle collide based on contactSpeed
                ballPaddleCollision(16 + offSet, contactPosition);
            };
            physicsMaterials[17].ContactProcessCallback = delegate(Vector3 contactPosition, Vector3 contactNormal,
             float contactSpeed, float colObj1ContactTangentSpeed, float colObj2ContactTangentSpeed,
             Vector3 colObj1ContactTangentDirection, Vector3 colObj2ContactTangentDirection)
            {
                // Method to play a sound when the ball and paddle collide based on contactSpeed
                ballPaddleCollision(17 + offSet, contactPosition);
            };
            physicsMaterials[18].ContactProcessCallback = delegate(Vector3 contactPosition, Vector3 contactNormal,
             float contactSpeed, float colObj1ContactTangentSpeed, float colObj2ContactTangentSpeed,
             Vector3 colObj1ContactTangentDirection, Vector3 colObj2ContactTangentDirection)
            {
                // Method to play a sound when the ball and paddle collide based on contactSpeed
                ballPaddleCollision(18 + offSet, contactPosition);
            };
            physicsMaterials[19].ContactProcessCallback = delegate(Vector3 contactPosition, Vector3 contactNormal,
             float contactSpeed, float colObj1ContactTangentSpeed, float colObj2ContactTangentSpeed,
             Vector3 colObj1ContactTangentDirection, Vector3 colObj2ContactTangentDirection)
            {
                // Method to play a sound when the ball and paddle collide based on contactSpeed
                ballPaddleCollision(19 + offSet, contactPosition);
            };
            physicsMaterials[20].ContactProcessCallback = delegate(Vector3 contactPosition, Vector3 contactNormal,
             float contactSpeed, float colObj1ContactTangentSpeed, float colObj2ContactTangentSpeed,
             Vector3 colObj1ContactTangentDirection, Vector3 colObj2ContactTangentDirection)
            {
                // Method to play a sound when the ball and paddle collide based on contactSpeed
                ballPaddleCollision(20 + offSet, contactPosition);
            };
            physicsMaterials[21].ContactProcessCallback = delegate(Vector3 contactPosition, Vector3 contactNormal,
             float contactSpeed, float colObj1ContactTangentSpeed, float colObj2ContactTangentSpeed,
             Vector3 colObj1ContactTangentDirection, Vector3 colObj2ContactTangentDirection)
            {
                // Method to play a sound when the ball and paddle collide based on contactSpeed
                ballPaddleCollision(21 + offSet, contactPosition);
            };
            physicsMaterials[22].ContactProcessCallback = delegate(Vector3 contactPosition, Vector3 contactNormal,
             float contactSpeed, float colObj1ContactTangentSpeed, float colObj2ContactTangentSpeed,
             Vector3 colObj1ContactTangentDirection, Vector3 colObj2ContactTangentDirection)
            {
                // Method to play a sound when the ball and paddle collide based on contactSpeed
                ballPaddleCollision(22 + offSet, contactPosition);
            };
            physicsMaterials[23].ContactProcessCallback = delegate(Vector3 contactPosition, Vector3 contactNormal,
             float contactSpeed, float colObj1ContactTangentSpeed, float colObj2ContactTangentSpeed,
             Vector3 colObj1ContactTangentDirection, Vector3 colObj2ContactTangentDirection)
            {
                // Method to play a sound when the ball and paddle collide based on contactSpeed
                ballPaddleCollision(23 + offSet, contactPosition);
            };
            physicsMaterials[24].ContactProcessCallback = delegate(Vector3 contactPosition, Vector3 contactNormal,
             float contactSpeed, float colObj1ContactTangentSpeed, float colObj2ContactTangentSpeed,
             Vector3 colObj1ContactTangentDirection, Vector3 colObj2ContactTangentDirection)
            {
                // Method to play a sound when the ball and paddle collide based on contactSpeed
                ballPaddleCollision(24 + offSet, contactPosition);
            };
            physicsMaterials[25].ContactProcessCallback = delegate(Vector3 contactPosition, Vector3 contactNormal,
             float contactSpeed, float colObj1ContactTangentSpeed, float colObj2ContactTangentSpeed,
             Vector3 colObj1ContactTangentDirection, Vector3 colObj2ContactTangentDirection)
            {
                // Method to play a sound when the ball and paddle collide based on contactSpeed
                ballPaddleCollision(25 + offSet, contactPosition);
            };
            physicsMaterials[26].ContactProcessCallback = delegate(Vector3 contactPosition, Vector3 contactNormal,
             float contactSpeed, float colObj1ContactTangentSpeed, float colObj2ContactTangentSpeed,
             Vector3 colObj1ContactTangentDirection, Vector3 colObj2ContactTangentDirection)
            {
                // Method to play a sound when the ball and paddle collide based on contactSpeed
                ballPaddleCollision(26 + offSet, contactPosition);
            };
            for (int i = 0; i < 27; i++)
                ((NewtonPhysics)scene.PhysicsEngine).AddPhysicsMaterial(physicsMaterials[i]);
        }
    }
}